/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			pglnwidth.h
  \date			Aug 2012
  \author		TNick

  \brief		Contains the definition for PgLnWidth class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __PGLNWIDTH_INC__
#define __PGLNWIDTH_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<cpg/logic/pgcharacteristic.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */
class	QDomElement;

namespace	cpg		{

class	CpgDoc;
class	PgCtx;
/**
*	@brief
*/
class PgLnWeight	: public PgCharacteristic			{
	BBM_TRACK( PgLnWeight );

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */


public:


	/**
	*	@brief	special values that mean something different than actual value
	*/
	enum	Id		{

		/* special codes */
		BYLAYER = PgCharacteristic::BYLAYER,
		BYBLOCK = PgCharacteristic::BYBLOCK,

		/* predefined codes */
		WEIGHT_SINGLE = -101,
		WEIGHT_DOUBLE = -102,
		WEIGHT_TRIPLE = -103,
		WEIGHT_HALF = -104,
		WEIGHT_QUARTER = -105

	};


	/**
	*	@brief	the container for the list of line width (in a document, for example)
	*/
	typedef	QList<Id>			List;


	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:


	/**
	*	@brief	actual scale
	*/
	qreal			weight_;


	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */


public:


	/**
	*	@brief	constructor
	*/
	PgLnWeight				( CpgDoc * doc );


	/**
	*	@brief	destructor
	*/
	~PgLnWeight				( void );


	/**
	*	@brief	report scale
	*/
	inline qreal			weight			( void )
	{ return weight_; }


	/**
	*	@brief	change scale
	*/
	inline void				setWeight		( qreal new_val )
	{ weight_ = new_val; }


	/**
	*	@brief	clone this characteristic in target ocument
	*/
	PgLnWeight *			clone			( CpgDoc * destin, int & idx );




	/* ******************************************************************* */
	/** @name 	Management methods                                         */
	/* ******************************************************************* */
	///@{


	/**
	*	@brief	tell if the id is inside allowed range
	*/
	static bool			isIdValid			( CpgDoc * doc, int id );


	/**
	*	@brief	get the weight for a particular code / explicit weight
	*/
	static qreal		explicitWeight			(
			PgCtx *				ctx,
			int					id
			);


	/**
	*	@brief	save a weight as a XML attribute for provided element
	*/
	static void			asXML			(
			PgCtx *				ctx,
			int					id,
			QDomElement &		dest
			);


	/**
	*	@brief	copies a color from source document to target document
	*
	*	@return	the id to be used in destination document
	*/
	static int				copy			(
			CpgDoc *				source,
			CpgDoc *				destin,
			int					value
			);


	///@}
	/* ******************************************************************* */



	/* ******************************************************************* */
	/** @name 	String related nethods                                     */
	/* ******************************************************************* */
	///@{


protected:


	/**
	*	@brief	get the name that coresponds to given id
	*/
	static QString			nameForId		( Id id );


	/**
	*	@brief	get the names and coresponding id for all codes
	*/
	static void				nameAndId		(
			QStringList &			name_list,
			QList<int> &			id_list
			);


public:


	/**
	*	@brief	get the string that represents this pattern
	*/
	static QString			asString		( CpgDoc * doc, int id );


	///@}
	/* ******************************************************************* */



	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class PgLnWeight	*/

/*  CLASS    =============================================================== */
//
//
//
//

}	//	namespace	cpg

#endif // __PGLNWIDTH_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
